package domd7;

import java.util.LinkedList;
import java.util.Queue;

public class MyQueue {
    public Queue<Integer> qu1;
    public Queue<Integer> qu2;
    public void mystatic(){
        qu1=new LinkedList<>();
        qu2=new LinkedList<>();
    }
    public int pop(){
      if(empty()){
          return -1;
      }

      if(!qu1.isEmpty()){
          int size=qu1.size();
          for (int i = 0; i <qu1.size()-1 ; i++) {
              qu2.offer(qu1.poll());
          }
          return qu1.poll();
      }else {
          int size=qu2.size();
          for (int i = 0; i <qu2.size()-1 ; i++) {
              qu1.offer(qu2.poll());
          }
          return qu2.poll();
      }
    }
   public boolean empty(){
        return qu1.isEmpty()&&qu2.isEmpty();
   }
}
